package com.hzlj.position.locate.common.common;

import com.fz.common.dict.annotation.Dict;
import com.hzlj.position.locate.common.dto.position.PositionQueryResultDTO;
import com.hzlj.position.locate.common.model.Position;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @author lifh
 * @date 2023/7/19 14:32
 **/
@Data
@Accessors(chain = true)
@NoArgsConstructor
public class PositionSimpleDTO {
    /**
     * 位置ID
     */
    private String id;
    /**
     * 经度
     */
    private String longitude;
    /**
     * 纬度
     */
    private String latitude;
    /**
     * 位置描述
     */
    private String position;
    /**
     * 定位时间-由设备产生
     */
    private Date positionTime;
    /**
     * 文件IDS
     */
    private String fileIds;
    /**
     * 告警类型,dict-LOCATE_WARNING_TYPE
     */
    @Dict("LOCATE_WARNING_TYPE")
    private String warningType;
    /**
     * 告警类型,dict-LOCATE_WARNING_TYPE(文本)
     */
    private String warningTypeText;

    public PositionSimpleDTO(
            String longitude,
            String latitude,
            String position) {
        this.longitude = longitude;
        this.latitude = latitude;
        this.position = position;
    }

    public PositionSimpleDTO(String id,
                             String longitude,
                             String latitude,
                             String position,
                             Date positionTime) {
        this.id = id;
        this.longitude = longitude;
        this.latitude = latitude;
        this.position = position;
        this.positionTime = positionTime;
    }

    public static PositionSimpleDTO from(PositionQueryResultDTO position) {
        return new PositionSimpleDTO(
                position.getId(),
                position.getLongitude(),
                position.getLatitude(),
                position.getPosition(),
                position.getPositionTime()
        );
    }

    public static PositionSimpleDTO from(Position position) {
        return new PositionSimpleDTO(
                position.getId(),
                position.getLongitude(),
                position.getLatitude(),
                position.getPosition(),
                position.getPositionTime()
        );
    }
}
